package top.cdmrx.demo.cms.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.cdmrx.common.R;
import top.cdmrx.demo.cms.entity.CrmBanner;
import top.cdmrx.demo.cms.service.CrmBannerService;

import java.util.List;

/**
 * Created by Mr.陈 time on 2021/11/26 | 13:41
 **/
@RestController
@RequestMapping("/cms/bannerfront")
@CrossOrigin
public class BannerFrontController {

    @Autowired
    private CrmBannerService bannerService;

    @Cacheable(key = "'selectIndexList'",value = "banner")
    @ApiOperation(value = "获取首页banner")
    @GetMapping("getAllBanner")
    public R index() {

        List<CrmBanner> list = bannerService.list(null);
        System.out.println("********************getAllBanner方法已经执行了***************************");
        return R.success().data("bannerList", list);
    }
}
